package com.ruoyi.demooo1.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.demooo1.domain.DictDivination;
import com.ruoyi.demooo1.mapper.DictDivinationMapper;
import com.ruoyi.demooo1.service.IDictDivinationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 卦象字典Service业务层处理
 *
 * @author ted
 * @date 2023-08-23
 */
@Service
public class DictDivinationServiceImpl implements IDictDivinationService {
    @Autowired
    private DictDivinationMapper dictDivinationMapper;

    /**
     * 查询卦象字典
     *
     * @param id 卦象字典主键
     * @return 卦象字典
     */
    @Override
    public DictDivination selectDictDivinationById(String id) {
        return dictDivinationMapper.selectDictDivinationById(id);
    }

    @Override
    public DictDivination selectDivinationFprDid(String dId) {
        return dictDivinationMapper.selectDivinationFprDid(dId);
    }

    /**
     * 查询卦象字典列表
     *
     * @param dictDivination 卦象字典
     * @return 卦象字典
     */
    @Override
    public List<DictDivination> selectDictDivinationList(DictDivination dictDivination) {
        return dictDivinationMapper.selectDictDivinationList(dictDivination);
    }

    /**
     * 新增卦象字典
     *
     * @param dictDivination 卦象字典
     * @return 结果
     */
    @Override
    public int insertDictDivination(DictDivination dictDivination) {
        Date nowDate = DateUtils.getNowDate();
        dictDivination.setCreateTime(nowDate);
        dictDivination.setId(UUID.randomUUID().toString().replace("-", ""));
        dictDivination.setCreateBy(SecurityUtils.getUserId().toString());
        dictDivination.setUpdateBy(SecurityUtils.getUserId().toString());
        dictDivination.setUpdateTime(nowDate);
        return dictDivinationMapper.insertDictDivination(dictDivination);
    }

    /**
     * 修改卦象字典
     *
     * @param dictDivination 卦象字典
     * @return 结果
     */
    @Override
    public int updateDictDivination(DictDivination dictDivination) {
        dictDivination.setUpdateTime(DateUtils.getNowDate());
        return dictDivinationMapper.updateDictDivination(dictDivination);
    }

    /**
     * 批量删除卦象字典
     *
     * @param ids 需要删除的卦象字典主键
     * @return 结果
     */
    @Override
    public int deleteDictDivinationByIds(String[] ids) {
        return dictDivinationMapper.deleteDictDivinationByIds(ids);
    }

    /**
     * 删除卦象字典信息
     *
     * @param id 卦象字典主键
     * @return 结果
     */
    @Override
    public int deleteDictDivinationById(String id) {
        return dictDivinationMapper.deleteDictDivinationById(id);
    }
}
